

#include "VFramework.h"
#include "VEventManager.h"
#include "VGameStageManager.h"


VFramework::VFramework()
    : mEventMgr(VNULL)
    , mGameStageMgr(VNULL)
{
    mEventMgr = new VEventManager();
	mGameStageMgr = new VGameStageManager();
}

VFramework::~VFramework()
{
    delete mGameStageMgr;
	mGameStageMgr = VNULL;
    
	delete mEventMgr;
	mEventMgr = VNULL;
}

void VFramework::startup(VRuntimeClass *stageClass)
{
    VEVENT_MANAGER.startup();
	VGAME_STAGE_MANAGER.startup(stageClass);
}

void VFramework::shutdown()
{
    VGAME_STAGE_MANAGER.shutdown();
	VEVENT_MANAGER.shutdown();
}

VBOOL VFramework::update(VUINT64 time, VUINT64 dt)
{
    VBOOL result = VGAME_STAGE_MANAGER.run(time, dt);
	if (!result)
		return VFALSE;
    
	VEVENT_MANAGER.dispatchEvent();
    
	return VTRUE;
}
